home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / DOpus-1541 / REXX / DOPUS / 1541 / 1541Dir.rexx < prev    next >
OS/2 REXX Batch file  |  1995-02-24  |  2KB  |  98 lines

  1. /*
  2.  *
  3.  * Enter a 1541 directory from DOpus.
  4.  *
  5.  * (c) 1995 by Christer Bjarnemo  mr.bjarnemo@mn.medstroms.se
  6.  *
  7.  * Based on Twin-Dopus by Patrick Van Beem (patrick.van.beem@aobh.xs4all.nl),
  8.  * which based he's script on the DOpusLhaARexx package by Geoff Seeley.
  9.  *
  10.  */
  11.  
  12. dircmd = "Work:Emulators/A64/Utils/"    /* Note. If the file ENVARC:1541.PREFS */
  13. rxdir =  "Rexx:Dopus/1541/"             /* exists, that one will override the  */
  14. tmpdir = "t:"                           /* settings here...                    */
  15. DOpusPort   = 'DOPUS.1'
  16.  
  17.  
  18. if ~show(l,"rexxsupport.library") then        
  19.     call addlib("rexxsupport.library",0,-30,0)
  20. if showlist('Ports', DOpusPort) = 0 then do
  21.    say 'Directory Opus Arexx port not found. Aborting.'
  22.    call CleanUp
  23. end
  24.  
  25.  
  26. if open(1,'env:1541.prefs','Read') then do
  27.         dircmd = readln(1)
  28.     rxdir  = readln(1)
  29.         tmpdir = readln(1)
  30.         end
  31. close(1)
  32.  
  33. dircmd = slashpath(dircmd)
  34. rxdir =  slashpath(rxdir)
  35. tmpdir = slashpath(tmpdir)
  36.  
  37. address(DOpusPort)
  38.  
  39. ClearWin
  40. busy on
  41. setwintitle '0K'
  42. TopText "Reading 1541 directory..."
  43.  
  44. address command dircmd'64dir $:* 8 >'tmpdir'_64dir.tmp'
  45.  
  46. if ~open(1,tmpdir'_64dir.tmp','Read') then do
  47.         TopText "ERROR - Couldnt locate tempfile..."
  48.     say 'ERROR - Couldnt locate tempfile...'
  49.     close 1
  50.     exit 20
  51.     end
  52.  
  53. do for 8; dskname = readln(1); end
  54.  
  55. if dskname ~='' then do
  56.     dskname = compress(substr(dskname,6,length(dskname)-9),'"')
  57.     end
  58. else do
  59.     dskname = 'Disk Error'
  60.     end
  61.  
  62. TopText 'Parsing files from 'dskname'...'
  63.  
  64. do until eof(1)
  65.     tmp = readln(1)
  66.     if word(tmp,3) = 'Status:' then status = tmp
  67.     if tmp ~= '' then do
  68.         fname = subword(tmp,2,words(tmp)-2)
  69.         fsize = word(tmp,1)
  70.         if fname = 'blocks' then do ; setwintitle quote(fsize/4'K   'dskname) ; fname = '' ; fsize = '' ; end
  71.         if left(fname,1) = '"' then do
  72.             fname = substr(fname,2,length(fname)-2)
  73.                     entry = quote(left(fname,30)''right(fsize*256,6)) quote(fname)' -1 -1 1 1'
  74.             Addcustentry entry
  75.             end
  76.         end
  77.     end
  78. 'DisplayDir -1'
  79. 'Addcustentry * 8 -1 -1 0 0'
  80.  
  81. TopText status
  82. busy off
  83. exit
  84.  
  85. Quote: procedure
  86.    parse arg string
  87. return '"'||string||'"'
  88.  
  89.  
  90. /*---------------------------------------------------------------------------*/
  91. Slashpath: procedure /* Put a (/) or (:) at the end of filenames (if neccessary) */
  92. parse arg string
  93.     if right(string,1) ~= ':' & right(string,1) ~= '/'  then do
  94.         string = string'/'
  95.         end
  96. return string
  97.  
  98.